package com.takeoff.iot.modbus.netty.data.factory;

import com.ruoyi.common.modbus.data.*;
import com.ruoyi.common.modbus.factory.MiiDataFactory;
import com.ruoyi.common.modbus.message.MiiMessage;

/**
 * 类功能说明：指令数据处理工厂<br/>
 * 公司名称：未可自动化 <br/>
 * 作者：weikeauto <br/>
 */
public class MiiServerDataFactory implements MiiDataFactory {

	@Override
	public MiiData buildData(int command, byte[] datas) {
		MiiData data = null;
		switch (command) {
		case MiiMessage.HEARTBEAT:
			data = new MiiHeartBeatData(datas);
			break;
		case MiiMessage.REGNO:
			data = new MiiLockData(datas);
			break;
		case MiiMessage.IOTDATA:
			data = new MiiHmDeviceData(datas);
			break;
		case MiiMessage.LOCATION:
			data = new MiiHmLocationData(datas);
			break;
		default: data = new MiiInData(datas);
			break;
		}
		return data;
	}

}
